<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="conversation.css" rel="STYLESHEET" type="text/css">
<title>Dialogue Act Label List</title>
<!--        Javascripts    -->
<jsp:include page="scripts/confirm.js" />
</head>
<body>
<!--        Header         -->
<jsp:include page="scripts/headerEdit.jsp">
	<jsp:param name="title" value="Statistics" />
</jsp:include>
<h2>Disagreement Matrices</h2>
<p>
<!--        Filter         -->
<jsp:include page="scripts/filter_by_annotators.jsp">
	<jsp:param name="file" value="viewstatistics.html" />
</jsp:include>
</p>

<p>
 Average Window Diff: <c:out value='${avgWD}' /> <br />
 Average Average Window Diff: <c:out value='${avgAvgWD}' />
</p>

<c:forEach items="${matrices}" var="matrix">
	<p>
	<table>
	  <tr>
	    <th>Annotator 1:</th>
	    <td><c:out value='${matrix.annotator1}'></c:out></td>
	  </tr>
	  <tr>
	    <th>Annotator 2:</th>
	    <td><c:out value='${matrix.annotator2}'></c:out></td>
	  </tr>
		<tr>
			<th>Number of conversation (Conversation IDs):</th>
			<td>             
				<c:out value='${matrix.numOfConversations}'></c:out> 
                <c:if test="${1 == 2}"> ( 
				<c:forEach items='${matrix.conversations}' var='conversation'>
				<c:out value='${conversation.conversationId}'></c:out>, 
					</c:forEach>) </c:if>
			</td>
		</tr>
		<tr>
			<th>Total number of messages (in each conversations):</th>
			<td>
				<c:out value='${matrix.numOfMessages}'></c:out> 
                <c:if test="${1==2}">( 
				<c:forEach items='${matrix.conversations}' var='conversation'>
							<c:out value='${conversation.numMessages}'></c:out>, 
				</c:forEach>
				)</c:if>					
			</td>
		</tr>
		<!-- 
		<tr>
			<th>Sums of Marginals:</th>
			<td><c:forEach items='${matrix.sumsOfMarginals}' var='sum'>
							<c:out value='${sum}'></c:out>, 
					</c:forEach>
			</td>			
		</tr>
		<tr>
			<th>Joint Marginal Proportions:</th>
			<td><c:forEach items='${matrix.jointMarginalProportions}' var='prop'>
							<c:out value='${prop}'></c:out>, 
					</c:forEach>
			</td>			
		</tr>
		-->
		<tr>
			<th>Level of Agreement:</th>
			<td><c:out value='${matrix.level}'></c:out>  </td>
		</tr>
		<tr>
			<th>Agreement (Total):</th>
			<td><c:out value='${matrix.agreementPercentile}'></c:out> % </td>
		</tr>
		<tr>
			<th>Agreement (Matched):</th>
			<td><c:out value='${matrix.agreementPercentileMatched}'></c:out> % </td>
		</tr>
		<tr>
			<th>Scott's pi:</th>
			<td><c:out value='${matrix.pi}'></c:out></td>
		</tr>
		<tr>
			<th>Cohen's kappa:</th>
			<td><c:out value='${matrix.kappa}'></c:out></td>
		</tr>
		<tr>
			<th>Total dialogue acts:</th>
			<td><c:out value='${matrix.annotationCount}'></c:out></td>
		</tr>
		<tr>
			<th>Agreed dialogue acts:</th>
			<td><c:out value='${matrix.agreedAnnotationCount}'></c:out></td>
		</tr>
		<tr>
			<th>Disagreed dialogue acts:</th>
			<td><c:out value='${matrix.disagreedAnnotationCount}'></c:out></td>
		</tr>
		<tr>
			<th>Matching dialogue acts not found:</th>
			<td><c:out value='${matrix.NAAnnotationCount}'></c:out></td>
		</tr>
		<tr>
			<th>Disagreements:</th>
			<td><c:forEach items="${matrix.topFiveDisagreementStrings}" var="disagreement">
					  <c:out value="${disagreement}"></c:out><br />
					</c:forEach>
            </td>       
		</tr>
	</table>
	</p>
	<p>
    <c:if test="${1 == 1}">
	<table>
		<tr>
			<td colspan="2" rowspan="2"></td>
			<td colspan="<c:out value='${fn:length(matrix.annotationLabels)}'/>">
			Annotator 1</td>
		</tr>

		<tr>

			<c:forEach items="${matrix.annotationLabels}" var="label"
				varStatus="status1">
				<td><c:out value="${label}" /></td>
			</c:forEach>
		</tr>

		<c:forEach items="${matrix.matrix}" var="row" varStatus="row_status">
			<tr>
				<c:if test="${row_status.count == 1}">
					<td
						rowspan="<c:out value='${fn:length(matrix.annotationLabels)}'/>">Annotator
					2</td>
				</c:if>
				<td><c:out value="${matrix.annotationLabels[row_status.count - 1]}" /></td>
				<c:forEach items="${row}" var="cell" varStatus="col_status">
                  <c:choose>
                    <c:when test="${row_status.count == col_status.count}">
                      <td style="background: #aaa;"><c:out value="${cell}" /></td>
                    </c:when>
                    <c:when test="${row_status.count % 2 == 0 || col_status.count % 2 == 0}">
                      <td style="background: #eee;"><c:out value="${cell}" /></td>
                    </c:when>
                    <c:otherwise>
					 <td><c:out value="${cell}" /></td>
                    </c:otherwise>
                  </c:choose>                  
				</c:forEach>
			</tr>
		</c:forEach>
	</table>
    </c:if>
	</p>
</c:forEach>

</body>
</html>
